package com.etc.service.impl;

import java.util.List;

import com.etc.dao.BroadcastingStationDao;
import com.etc.dao.MusicDao;
import com.etc.dao.impl.BroadcastingStationDaoImpl;
import com.etc.dao.impl.MusicDaoImpl;
import com.etc.entity.BroadcastingStation;
import com.etc.entity.PageInfo;
import com.etc.service.BroadcastingStationService;

public class BroadcastingStationServiceImpl implements BroadcastingStationService{
	private MusicDao musicDao = new MusicDaoImpl(); 
	private BroadcastingStationDao broadcastingStationDao = new BroadcastingStationDaoImpl();
	/**
	 * 根据条件查询电台歌单
	 */
	@Override
	public List<BroadcastingStation> getBroadcastingStations(String zt) {
		// TODO Auto-generated method stub
		
		
		return broadcastingStationDao.find(zt);
	}
	/**
	 * 根据条件组合查询歌单及分页
	 */
	@Override
	public PageInfo<BroadcastingStation> findBroadcastingStationsByCondition(String languagesName, String styleName,
			String themeName, String moodName, String sceneName, int pageNum, int pageSize) {
		// 调用dao层获取分页结果集
		List<BroadcastingStation> data=broadcastingStationDao.findByConditions(languagesName, styleName, themeName, moodName, sceneName, pageNum, pageSize);
		// 调用dao层获取分页之前的总记录数
		Integer total =broadcastingStationDao.countByCondition(languagesName, styleName, themeName, moodName, sceneName);
		
		// 构建PageInfo对象
		PageInfo<BroadcastingStation> pageInfo = new PageInfo<BroadcastingStation>(data, pageNum, pageSize, total);
		
		return pageInfo;
	}
	@Override
	public int getMusicByCondition(int BroadcastingStationId) {
		// TODO Auto-generated method stub
		int n = broadcastingStationDao.findFirstByBroadcastingStation(BroadcastingStationId);
		
		return n;
	}
	@Override
	public BroadcastingStation getBroadcastingStationById(int broadcastingStationId) {
		// TODO Auto-generated method stub
		
		return broadcastingStationDao.findBroadcastingStationById(broadcastingStationId, musicDao.findByBroadcastingStationId(broadcastingStationId));
	}
	@Override
		public List<BroadcastingStation> findByUserId(Integer userId) {
		// TODO Auto-generated method stub
		return broadcastingStationDao.findByUserId(userId);
	}
}
